<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>淘惠帮</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href="${resources}/plugins/fontAwesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/common.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/myaddress.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container">
    <div class="commonHeader">我的地址
        <a href="javascript:history.back(-1);" class="fa fa-chevron-left back"></a>
    </div>

    <ul class="addressList">
    	<#list addressList as address>
    	<li>
            <div class="address">
                <div class="name">
                    <span>${address.name}</span>
                    <span class="phone">${address.telephone}</span>
                </div>
                <div class="address1">
                    <p>${address.address}${address.street}</p>
                </div>
            </div>

            <div class="option">
                
                
                
                <#if address.isDefault==1>
					<input name="Fruit" id="Fruit" type="radio" onchange="addressCheck(${address.id})" checked="checked" value="">
	                <span class="acquiesce">默认地址</span>
                <#else>
					<input name="Fruit" id="Fruit" type="radio"  onchange="addressCheck(${address.id})" value="">
	                <span>设为默认</span>
                </#if>
                <div class="handle">
                	<a href="${path}/manage/address/send/${address.id}"  > 返回订单</a>
                    <a href="${path}/manage/address/update/${address.id}?prevurl=manage/address/select"><span class="fa fa-file-text"></span>编辑</a>
                    <a href="javascript:void(0)" onclick="deleteAddress(${address.id})" ><span class="fa fa-trash-o"></span>删除</a>
                </div>
            </div>
        </li>
    	</#list>
    </ul>
    <div class="bottomBtn">
        <a href="${path}/manage/address/create?prevurl=manage/address/select">新增地址</a>
    </div>
</div>
</body>
<script src="${resources}/js/jquery-2.2.2.min.js"></script>
<script src="${resources}/js/common.js"></script>

<script>
	
	

	function addressCheck(addressId){
		$.ajax({
 	        url: "${path}/manage/address/updateDefault?addressId="+addressId,
 	        type: "post",
 	        success: function(data) {
 	        	if(data.code == "000"){
 	        		window.location.reload();
 	        	}
 	        }
 		})
	}
	
	function deleteAddress(addressId){

		common.alert({
		    dialog: true,
			content:'确认删除',
			ok:function(){
				window.location.href="${path}/manage/address/delete/"+addressId+"?prevurl=manage/address/select";
			},
			cancelValue:'取消',
			cancel:function(){
			}
		})
	}
	
	function send(id){
		window.location.href="${path}/manage/address/send/"+id;
	}
 	    
</script>

</html>